package com.hujf.netty.nio.zerocopy;

import java.io.*;
import java.net.Socket;

/**
 * @author Hujf
 * @title: OldIoClient
 * @date 2021/1/26 0026下午 4:34
 * @description: TODO
 */
public class OldIoClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost",7001);
        String file = "F:\\百度云下载\\47821，郑人杰 软件工程概论（第2版）.zip";
        InputStream inputStream = new FileInputStream(file);
        DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());

        long start = System.currentTimeMillis();
        byte[] buffer = new byte[4096];
        long read;
        long total=0;
        while((read=inputStream.read(buffer))!=-1){
            total+=read;
            dataOutputStream.write(buffer);
        }
        System.out.println("发生了字节："+total+" 耗时"+(System.currentTimeMillis() -start));
        dataOutputStream.close();
        socket.close();
        inputStream.close();
    }
}
